package com.ficus.road.maintain.dao;

import com.ficus.road.maintain.core.dao.BaseMongoDao;
import com.ficus.road.maintain.core.model.Hit;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 智慧决策道路病害详情弹窗
 */
@Component
public class HitRoadCorrelationDao extends BaseMongoDao<Hit, String> {

    @Override
    public String getCollectionName() {
        return "hit";
    }


    public List<Hit> RoadCorrelation(Query query,int pageNumber, int pageSize) {
        // 创建分页请求对象
        PageRequest pageRequest = PageRequest.of(pageNumber, pageSize, Sort.by(Sort.Direction.DESC, "create_time"));
        // 设置分页参数
        query.with(pageRequest);
        return this.findByQuery(query);
    }

    public Long getRoadCorrelationCount(Query query) {
        return this.count(query);
    }
}
